package com.qianfeng.tools;

import com.qianfeng.project.R;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

/**
 * @author SAMSUNG
 * 单例模式
 *
 */
public class ActivityBack implements OnClickListener{
	private LinearLayout btn_back;
	private Activity activity;
	private static ActivityBack activityBack;
	private int id;
	
	private ActivityBack(Activity activity) {
		this.activity = activity;
		btn_back = (LinearLayout) activity.findViewById(R.id.btn_back);
		btn_back.setOnClickListener(this);
	}

	public static ActivityBack getInstance(Activity activity) {
		activityBack = new ActivityBack(activity);
		return activityBack;
	}

	@Override
	public void onClick(View v) {
		id = v.getId();
		if (id == R.id.btn_back) {
			if (activityBack != null) {
				activityBack = null;
			}
			activity.finish();
		}
	}


}
